]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
main: Move pref overrides back into C
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 5 Jun 2014 16:09:47 +0000 (18:09 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Mon, 9 Jun 2014 19:52:03 +0000 (21:52 +0200)
Commit 6c2f3d1d178a65d moved pref overrides into JS to implement
session mode specific overrides in a clean and generic way.
However that approach comes with a cost - doing the overrides only
after having handled over control to JS means that the core will
be initialized with the non-overridden settings before changing
to the correct values. In the best case this is unnecessary work,
but it can in fact have a worse effect: when initializing workspaces,
we will restore the previous number of workspaces when using
dynamic-workspaces and reset to the configured number otherwise.
As the non-overridden default for dynamic-workspaces is FALSE, we
can easily end up moving the user's windows to the "wrong" workspace.

Now GSettings is expected to grow support for session specific defaults,
which will render our entire override system obsolete (yay!). Given
that, it seems acceptable to use a less generic (and uglier) approach
in the meanwhile, in order to fix aforementioned problems. So move
overrides back before core initialization and just hardcode the
session-mode => override-schema relation.

https://bugzilla.gnome.org/show_bug.cgi?id=695487

js/ui/main.js
js/ui/windowManager.js
src/main.c
src/shell-global.c
src/shell-global.h

index a21af899f8b90436146fd4c1021a759c859818ec..6218f33d5c6064c350d6664461ccc901868fad2f 100644 (file)
@@ -74,7 +74,6 @@ let _startDate;
 let _defaultCssStylesheet = null;
 let _cssStylesheet = null;
 let _a11ySettings = null;
-let dynamicWorkspacesSchema = null;
 
 function _sessionUpdated() {
     _loadDefaultStylesheet();
@@ -111,7 +110,6 @@ function start() {
 
     sessionMode = new SessionMode.SessionMode();
     sessionMode.connect('updated', _sessionUpdated);
-    _initializePrefs();
     _initializeUI();
 
     shellDBusService = new ShellDBus.GnomeShell();
@@ -120,17 +118,6 @@ function start() {
     _sessionUpdated();
 }
 
-function _initializePrefs() {
-    let keys = new Gio.Settings({ schema: sessionMode.overridesSchema }).list_keys();
-    for (let i = 0; i < keys.length; i++)
-        Meta.prefs_override_preference_schema(keys[i], sessionMode.overridesSchema);
-
-    if (keys.indexOf('dynamic-workspaces') > -1)
-        dynamicWorkspacesSchema = sessionMode.overridesSchema;
-    else
-        dynamicWorkspacesSchema = 'org.gnome.mutter';
-}
-
 function _initializeUI() {
     // Ensure ShellWindowTracker and ShellAppUsage are initialized; this will
     // also initialize ShellAppSystem first.  ShellAppSystem
index 0b77916b06743f8dc4942316961d667b8b543f63..c2a2d133f656fbd1aa6aa0c9626f6a428d66d926 100644 (file)
@@ -199,12 +199,19 @@ const WorkspaceTracker = new Lang.Class({
         global.screen.connect('window-left-monitor', Lang.bind(this, this._windowLeftMonitor));
         global.screen.connect('restacked', Lang.bind(this, this._windowsRestacked));
 
-        this._workspaceSettings = new Gio.Settings({ schema: Main.dynamicWorkspacesSchema });
+        this._workspaceSettings = this._getWorkspaceSettings();
         this._workspaceSettings.connect('changed::dynamic-workspaces', Lang.bind(this, this._queueCheckWorkspaces));
 
         this._nWorkspacesChanged();
     },
 
+    _getWorkspaceSettings: function() {
+        let settings = global.get_overrides_settings();
+        if (settings.list_keys().indexOf('dynamic-workspaces') > -1)
+            return settings;
+        return new Gio.Settings({ schema: 'org.gnome.mutter' });
+    },
+
     _checkWorkspaces: function() {
         let i;
         let emptyWorkspaces = [];
index 55f6683949ac4188ca431e24d728d52287f99263..a2f497cf80b976f3e76804142c9ba8f736a6abc3 100644 (file)
@@ -34,6 +34,8 @@ extern GType gnome_shell_plugin_get_type (void);
 #define SHELL_DBUS_SERVICE "org.gnome.Shell"
 #define MAGNIFIER_DBUS_SERVICE "org.gnome.Magnifier"
 
+#define OVERRIDES_SCHEMA "org.gnome.shell.overrides"
+
 #define WM_NAME "GNOME Shell"
 #define GNOME_WM_KEYBINDINGS "Mutter,GNOME Shell"
 
@@ -167,6 +169,23 @@ shell_dbus_init (gboolean replace)
   g_object_unref (session);
 }
 
+static void
+shell_prefs_init (void)
+{
+  ShellGlobal *global = shell_global_get ();
+  GSettings *settings = shell_global_get_overrides_settings (global);
+  char **keys, **k;
+
+  if (!settings)
+    return;
+
+  keys = g_settings_list_keys (settings);
+  for (keys = k = g_settings_list_keys (settings); *k; k++)
+    meta_prefs_override_preference_schema (*k, OVERRIDES_SCHEMA);
+
+  g_strfreev (keys);
+}
+
 static void
 shell_introspection_init (void)
 {
@@ -434,6 +453,8 @@ main (int argc, char **argv)
 
   _shell_global_init ("session-mode", session_mode, NULL);
 
+  shell_prefs_init ();
+
   ecode = meta_run ();
 
   if (g_getenv ("GNOME_SHELL_ENABLE_CLEANUP"))
index f945e36f4a74222cd86ed66e3e3d4127e0eb5d80..18e3e099314334f331d4e1e235d82be46093cd7c 100644 (file)
@@ -1355,6 +1355,37 @@ shell_global_get_settings (ShellGlobal *global)
   return global->settings;
 }
 
+/**
+ * shell_global_get_overrides_settings:
+ * @global: A #ShellGlobal
+ *
+ * Get the session overrides GSettings instance.
+ *
+ * Return value: (transfer none): The GSettings object
+ */
+GSettings *
+shell_global_get_overrides_settings (ShellGlobal *global)
+{
+  static GSettings *settings = NULL;
+  const char *schema;
+
+  g_return_val_if_fail (SHELL_IS_GLOBAL (global), NULL);
+
+  if (!settings)
+    {
+      if (strcmp (global->session_mode, "classic") == 0)
+        schema = "org.gnome.shell.extensions.classic-overrides";
+      else if (strcmp (global->session_mode, "user") == 0)
+        schema = "org.gnome.shell.overrides";
+      else
+        return NULL;
+
+      settings = g_settings_new (schema);
+    }
+
+  return settings;
+}
+
 /**
  * shell_global_get_current_time:
  * @global: A #ShellGlobal
index 71bdf7d8513617983d03d670221b9a67b3606a9f..a5630ecd37f1f015455ed858e47977409b4918c6 100644 (file)
@@ -35,6 +35,7 @@ GdkScreen     *shell_global_get_gdk_screen            (ShellGlobal *global);
 MetaDisplay   *shell_global_get_display               (ShellGlobal *global);
 GList         *shell_global_get_window_actors         (ShellGlobal *global);
 GSettings     *shell_global_get_settings              (ShellGlobal *global);
+GSettings     *shell_global_get_overrides_settings    (ShellGlobal *global);
 guint32        shell_global_get_current_time          (ShellGlobal *global);